package com.zhang.spring.task;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Scanner;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户");
        String un = sc.next();
        System.out.println("请输入密码");
        String pw = sc.next();

        if (!(un.length()<5||un.length()>15)){
            System.out.println("用户不正确");
        }
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql//master:3306/bjpowernode", "root", "123456");
        String sql="select * from user where username=?";

        PreparedStatement ps = con.prepareStatement(sql);

        ps.setString(1,"un");
        ResultSet rs = ps.executeQuery();
        if (!rs.next()){

            System.out.println("用户不存在");
        }

        User user = new User(rs.getInt("id"),
                rs.getString("username"),
                rs.getString("password"));



    }
}
